package blackhouse_server;

import java.sql.SQLException;
import java.util.List;

import blackhouse_dao.teacher_dao;
import blackhouse_entity.teacher;

public class teacher_info_server
{
	teacher_dao	td	= new teacher_dao();

	public List<teacher> showtinfo(String code, String ID) throws SQLException
	{
		String sql = "SELECT * FROM teacher";
		if (code.equals("3"))
		{
			sql += " where tCode = '" + ID + "'";
		}
		return td.queryGradeByList(sql);
	}

	public boolean deltinfo(String ID) throws SQLException
	{
		String sql = "select id from teacher where tCode = '" + ID + "'";
		int num = td.cheekID(sql);
		sql = "DELETE FROM tclass where tID = '" + num + "'";
		if (td.addGradeInfo(sql) > 0)
		{
			sql = "DELETE FROM teacher WHERE tCode ='" + ID + "'";
			if (td.addGradeInfo(sql) > 0)
			{
				sql = "DELETE FROM login WHERE code ='" + ID + "'";
				return td.addGradeInfo(sql) > 0;
			} else
			{
				return false;
			}
		} else
		{
			return false;
		}

	}

	public List<teacher> seektinfo(String ID) throws SQLException
	{
		String sql = "SELECT * FROM teacher where tName Like'%" + ID + "%'";
		return td.queryGradeByList(sql);
	}

}
